<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>实战数组的几种运算</title>
		<script>
			// 求数组的最大值
			var arr = [100,87,45,12,5,54,23];
			console.log(arr);
			max = arr[0];
			for(var i=0; i<arr.length; i++){
				if(arr[i] > max){
					max = arr[i]
				}
			}
			console.log(max);
			// 最小值
			min = arr[0];
			for(var i=0; i<arr.length; i++){
				if(arr[i] < min){
					min = arr[i]
				}
			}
			console.log(min);
			// 求和
			sum = 0;
			for(var i=0; i<arr.length; i++){
				sum+=arr[i];
			}
			console.log(sum);
			// 求平均值
			console.log(sum/arr.length);
			
			console.log(Math.max(arr));
			console.log(Math.max(100,87,45,12,5,54,23));
			console.log(Math.max.apply(null,arr));
			console.log(Math.min.apply(null,arr));
		</script>
	</head>
	<body>
	</body>
</html>